// import { getCityList } from '@/api/app.js'

export default {
	state: {
		city: {
			code: 110100,
			name: '北京市'
		}, // 当前选择城市
		supportCitys: {
			hotList: [],
			cityList: []
		}, // 支持的城市列表
		dateValue: {
			startDate: new Date(),
			endDate: new Date(new Date().getTime() + 24 * 3600 * 1000),
			onlineDate:'',
			dayCount: 1,
			maxCanCheckInStock:1 //最大可以预订的房间数量
		},
		currentHouse: {
					"landlordSn": "",
					"landlordName": "",
					"landlordAvatar": "",
					"personalSign": "",
					"houseCount": 0,
					"attentionCount": 0,
					"houseSn": "",
					"name": "",
					"collectCount": 0,
					"scanCount": 0,
					"commentCount": 0,
					"waitLiveCount": 0,
					"category": 0,
					"categoryName": "",
					"recommendTentantCount": 0,
					"roomArea": 0,
					"houseStructure": "",
					"houseAttachmentVos": [],
					"rentPrice": 0,
					"province": "",
					"provinceName": "",
					"city": "",
					"cityName": "",
					"area": "",
					"areaName": "",
					"addr": "",
					"street": null,
					"houseNearbyDescription": null,
					"normalPrice": 0,
					"weekendPrice": 0,
					"holidayPrice": 0,
					"houseCommentVos": [],
					"collect": false,
					"wantLive": false,
					"attentionLandlord": false
				},
				systemMessage: [],
		
		searchCity:{
			
		},
		listInScreenContentIds:[]
	},
	mutations: {
		SET_LISTINSCREENCONTENTIDS(state, ids) {
			state.listInScreenContentIds = ids
		},
		SET_CITY_LIST(state, support) {
			// 设置已开通城市列表
			state.supportCitys = Object.assign({}, state.supportCitys, support)
		},
		SET_CITY(state, city) {
			// 设置当前城市
			state.city = Object.assign({}, state.city, city)
		},
		CLEAR_SEARCH_CITY(state){
			state.searchCity ={}
		},
		SET_SEARCH_CITY(state, city) {
			// 设置当前城市
			state.searchCity = Object.assign({}, state.searchCity, city)
		},
		SET_DATE(state, dateValue) {
			// 设置选择日期
			let { startDate, endDate, dayCount ,maxCanCheckInStock,onlineDate} = dateValue;
			state.dateValue = { startDate, endDate, dayCount ,maxCanCheckInStock,onlineDate};
		},
		SET_CURRENT_HOUSE(state, detail) {
			// 设置当前房源
			state.currentHouse = detail
		},
		SET_SYSTEM_MESSAGE(state, list) {
			// 设置系统消息
			state.systemMessage = list
		}
	},
	actions: {
		getCityList({ commit }) {
			// 请求所有已开通的城市, 可选 传入省份code
			getCityList().then(res => {
				let { data } = res;
				commit('SET_CITY_LIST', data);
			})
		}
	},
	getters: {
		dateValue: state => state.dateValue,
		cityList: state => state.supportCitys.cityList,
		hotList: state => state.supportCitys.hotList,
		currentHouse: state => state.currentHouse,
		systemMessage: state => state.systemMessage,
		searchCity: state => state.searchCity,
		listInScreenContentIds: state => state.listInScreenContentIds,
	}
}